import request from "@/api/http";
export interface PostApi {
    content: string,
    imageKey: Object,
    isShared: boolean,
    shareId?: string,
}
export const sendPostApi = (param: PostApi) => {
    return request({
        url: '/post/send_post',
        method: 'post',
        data: {
            ...param,
        }
    })
}

export const getPostListApi = (userId: string) => {
    return request({
        url: `/post/get_post_list?userId=${userId}`,
        method: 'get',
    })
}

export const getPostApi = (postId: string) => {
    return request({
        url: `/post/get_post?postId=${postId}`,
        method: 'get'
    })
}

export const getEnterprisePostApi = (enterpriseId: string) => {
    return request({
        url: `/post/get_enterprise_post?enterpriseId=${enterpriseId}`,
        method: 'get'
    })
}

export const deletePostApi = (postId: string) => {
    return request({
        url: `/post/delete_post`,
        method: 'post',
        data: {
            postId
        }
    })
}

export const likeApi = (postId: string) => {
    return request({
        url: `/post/like`,
        method: 'put',
        data: {
            postId,
        }
    })
}

export const sendCommentApi = (postId: string, content: string) => {
    return request({
        url: `/post/send_comment`,
        method: 'post',
        data: {
            postId,
            content
        }
    })
}

export const getCommentsApi = (postId: string, count?: string) => {
    let url = `/post/get_comments?postId=${postId}`;
    if (count) {
        url += `&count=${count}`;
    }
    return request({
        url: url,
        method: 'get',
    });
}

export const getInfoApi = (userId: string) => {
    return request({
        url: `/post/get_info?userId=${userId}`,
        method: 'get'
    })
}